#ifndef SEGMENT_CONTAINER_HPP
#define SEGMENT_CONTAINER_HPP

//------------------------------------------------------------------------------
// Fichier d'entête utilisés
//------------------------------------------------------------------------------
#include <list>
#include "Tools/Logger.hpp"
namespace ImageAnalysis
{

//----------------------------------------------------------------------
//
//----------------------------------------------------------------------
class SegmentContainer
{
public:
		//----------------------------------------------------------------------
		// Structure
		//----------------------------------------------------------------------		
		struct Coordinates
		{
			int x;
			int y;
			Coordinates( int _x, int _y)
			{
				x = _x;
				y = _y;
			}
		};

		struct Segment
		{
			Coordinates *  begin;
			Coordinates *  end;

			Segment(Coordinates *  _begin, Coordinates * _end)
			{
				begin = _begin;
				end = _end;
			}
			Segment( int beginX, int beginY, int endX, int endY )
			{
				begin = new Coordinates(beginX, beginY);
				end   = new Coordinates(endX, endY);
			}
			~Segment()
			{
				delete begin;
				delete end;
			}
		};
 
		typedef std::list< Segment* >::iterator TSegmentContainerIterator;
		typedef std::list< SegmentContainer* >  TSegmentContainerList;
		//----------------------------------------------------------------------
		// Constructeur
		//----------------------------------------------------------------------
		SegmentContainer( int width, int height );
		
		//----------------------------------------------------------------------
		// Destructeur
		//----------------------------------------------------------------------
		virtual ~SegmentContainer();

		//----------------------------------------------------------------------
		// 
		//----------------------------------------------------------------------
		int GetHeight( ) { return imageHeight; };
		//----------------------------------------------------------------------
		// 
		//----------------------------------------------------------------------
		int GetWidth( ) { return imageWidth; };

		//----------------------------------------------------------------------
		// 
		//----------------------------------------------------------------------
		int GetNumberOfSegments( );

		//----------------------------------------------------------------------
		// 
		//----------------------------------------------------------------------
		void AddSegment( Segment* segment );

		//----------------------------------------------------------------------
		// Méthode 
		//----------------------------------------------------------------------
		TSegmentContainerIterator GetStartSegment( );

		//----------------------------------------------------------------------
		// 
		//----------------------------------------------------------------------
		TSegmentContainerIterator GetEndSegment( );

		void Print( )
		{
			TSegmentList::iterator it;
			for( it = segmentList.begin(); it != segmentList.end(); ++it )
			{
				Tools::ILogger::Log( "begin[x:%d,y:%d] end[x:%d,y:%d]\n", (*it)->begin->x, (*it)->begin->y, (*it)->end->x, (*it)->end->y);
			}
		}
	
private:
		//----------------------------------------------------------------------
		//
		//----------------------------------------------------------------------
		typedef std::list<Segment*> TSegmentList;
		TSegmentList segmentList;
		int imageWidth;
		int imageHeight;
		
		//----------------------------------------------------------------------
		// Constructeur par copie et oprérateur d'affectation en privée pour
		// interdire leur utilisation
		//----------------------------------------------------------------------
		SegmentContainer( const SegmentContainer& copy);
		SegmentContainer& operator=( const SegmentContainer& copy );
};

}

#endif //SEGMENT_CONTAINER_HPP
